<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 老式写法 */
        let str = '<a href="https://www.baidu.com">百度</a>'

        // 1.提取url和标签文本
        const reg = /<a href="(.*)">(.*)<\/a>/
        
        // 2.执行
        const result = reg.exec(str);

        console.log(result[1]);
        console.log(result[2]);


        /* 分组写法 */ 
        // 1.提取url和标签文本并分组
        const reg2 = /<a href="(?<url>.*)">(?<text>.*)<\/a>/;
        // 2.执行
            const result2 = reg2.exec(str)
        console.log(result2.groups.url);
        console.log(result2.groups.text);
    </script>
</body>
</html>